<?php

namespace App\Requests;

use App\Services\CommonService;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Http\Exceptions\HttpResponseException;

class BaseRequest extends FormRequest
{
    protected function failedValidation(Validator $validator)
    {
        throw new HttpResponseException(response()->json([
            'code' => CommonService::HTTP_CODE_FAIL,
            'msg' => $validator->errors()->first(),
            'data' => null
        ]));
    }
}
